package com.ssy.jt808.gateway.sdk.terminal.pojo.info.alarm;

import com.fasterxml.jackson.databind.JsonNode;
import com.ssy.gaea.util.JsonMapper;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;

/**
 * @author zeno
 */

@Data
public class TerminalAlarmInfo{

  /** 定位 ID */
  private Long locationId;

  /** 定位时间 */
  private LocalDateTime locationTime;

  /** 定位报警位 */
  private List<JsonNode> locationAlarms;

  /** Adas 报警 */
  private AdasAlarmInfo adasAlarm;

  /** Dsm 报警 */
  private DsmAlarmInfo dsmAlarm;

  /** 激烈驾驶 */
  private AdAlarmInfo adAlarm;

  public void addLocationAlarmInfo( LocationAlarmInfo alarmInfo ){
    if( this.locationAlarms == null ){
      this.locationAlarms = new LinkedList<>();
    }

    this.locationAlarms.add(JsonMapper.toJsonNode(alarmInfo));
  }


  public boolean existsAlarm(){
    return !CollectionUtils.isEmpty(locationAlarms)
           || adasAlarm != null
           || dsmAlarm != null
           || adAlarm != null;
  }
}
